package com.app.piemoment;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.app.piemoment.entity.PieUser;
import com.app.piemoment.view.PmDialog;

public class ComplateUserInfo2Activity extends Activity {
	public int sex = 1;

	EditText height_EditText, figure_EditText, edu_EditText, school_EditText;
	SharedPreferences userInfo;
	Button ok_Button;
	public static String[] edu = new String[] { "专科", "本科", "硕士", "博士" };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.regedit_info_step2);
		userInfo = getSharedPreferences(BaseActivity.PREF_NAME,
				MODE_WORLD_READABLE);

		height_EditText = (EditText) findViewById(R.id.height_EditText);
		figure_EditText = (EditText) findViewById(R.id.figure_EditText);
		edu_EditText = (EditText) findViewById(R.id.edu_EditText);

		edu_EditText.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				PmDialog.createListView(ComplateUserInfo2Activity.this, edu, 0,
						new OnClickListener() {
							@Override
							public void onClick(DialogInterface dialog,
									int which) {
								edu_EditText.setText(edu[which]);
							}
						});

			}
		});
		school_EditText = (EditText) findViewById(R.id.school_EditText);

		ok_Button = (Button) findViewById(R.id.ok_button);
		ok_Button.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				userInfo.edit()
						.putString(PieUser.height_S,
								height_EditText.getText().toString()).commit();
				userInfo.edit()
						.putString(PieUser.weight_S,
								figure_EditText.getText().toString()).commit();
				userInfo.edit()
						.putString(PieUser.degree_S,
								edu_EditText.getText().toString()).commit();
				userInfo.edit()
						.putString(PieUser.school_S,
								school_EditText.getText().toString()).commit();

				Intent intent = new Intent();
				intent.setClass(ComplateUserInfo2Activity.this,
						
						ComplateUserInfo3Activity.class);
				startActivity(intent);

			}
		});

	}

}
